package com.briup.pts.web.controller;

import com.briup.pts.config.response.Result;
import com.briup.pts.domain.bean.Log;
import com.briup.pts.service.LogService;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wy
 * @description
 * @data 2024/11/29  10:37
 */
@Tag(name = "日志模块")
@Slf4j
@Validated
@RequestMapping("/log")
@RequiredArgsConstructor
@RestController
public class LogController {
    private final LogService service;

    @Operation(summary = "分页并根据条件查询动物基本信息以及对应批次和栏舍栏圈信息")
    @GetMapping("/page")
    public Result<?> pageQuery(@NotNull(message = "分页参数不能为空")
                               @Min(value = 1L, message = "当前页面不能小于1") Integer pageNum,
                               @Min(value = 1L, message = "页面大小不能小于1")
                               @NotNull(message = "分页参数不能为空") Integer pageSize,
                               String originalIp) {
        // 调用service层方法，时间分页多条件查询
        PageInfo<Log> pageInfo = service
                .pageQueryByCondition(pageNum, pageSize,originalIp);

        return Result.success(pageInfo)
                .apply("获取成功");
    }
}
